<!DOCTYPE html>
<html>
<head lang="en">
    <title>Excel导入</title>
    <LINK rel="stylesheet" href="../static/resources/bootstrap/css/bootstrap.css">
    <script src="../static/resources/js/jquery/jquery-3.1.1.min.js" type="text/javascript"></script>
    <script src="../static/resources/bootstrap/js/bootstrap.js" type="text/javascript"></script>
</head>
<body>
<div style="width: 300px; margin: 50px auto;">
    <form role="form" action="/fileUpload" method="post" enctype="multipart/form-data">
        <div class="form-group">
            <label for="download">下载模板: </label><br>
            <a id="download" href="/static/xlsx/user.xlsx"
               style="color:rgb(22,22,22);text-decoration: underline;"><h3>点击下载模板</h3></a>
        </div>
        <div class="form-group">
            <label for="inputfile">上传模板: </label>
            <input type="file" id="inputfile" name="fileName" class="btn btn-default">
        </div>
        <button type="button" id="button" class="btn btn-primary">提交</button>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
    $(function () {
        $("#button").click(function () {
            var formData = new FormData();
            var file = $(':file').prop('files');
            formData.append("fileName", file[0]);
            $.ajax({
                type: 'post',
                url: '/fileUploadUser',
                data: formData,
                cache: false,
                processData: false,  //tell jQuery not to process the data
                contentType: false,  //tell jQuery not to set contentType
                success: function (data) {
                    alert(data);
                }, error: function () {
                 //   alert("异常");
                }
            })
        })
    })
</script>